#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main(int argc, char const *argv[])
{
    map<pair<int, int>, int> temps;
    int n, k, *x, nmin, i, mm = 2147483647;
    long long sum;
    cin >> n >> k;
    x = new int[n];
    int sm = 0;
    for (i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    sum = 0;
    nmin = n + 1;
    for (i = 0; i < n; i++)
    {
        int j = 0;
        j = temps[make_pair(x[i], 0)];
        temps[make_pair(x[i], 0)]++;
        temps[make_pair(x[i], j)]++;
        mm = min(mm, x[i]);
        sum += x[i];
        while (sum - (*temps.begin()).first.first * 2 >= k)
        {
            sum -= (*temps.begin()).first.first * 2;
            if ((*temps.begin()).second)
                temps.erase(temps.begin());
            else
                temps.erase(temps.begin());
        }
        if (sum >= k)
        {
            nmin = min(nmin, (int)temps.size());
        }
    }
    cout << ((nmin == n + 1) ? -1 : nmin);
    return 0;
}